﻿<controls:ChildWindow 
    x:Class="KharaPos.Views.Catalog.AddCategoryWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:controls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls"
    xmlns:DataForm="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data.DataForm.Toolkit" xmlns:DataSource="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.DomainServices" xmlns:my="clr-namespace:KharaPos.Web.Services" Title="AddCategoryWindow"
    Width="600">
    <Grid x:Name="LayoutRoot" Margin="2">
        <Grid.Resources>
            <DataSource:DomainDataSource
                        x:Key="LookupSource"
                        AutoLoad="True"
                        Height="0"
                        QueryName="GetCategoriesQuery"
                        Width="0">
                <DataSource:DomainDataSource.DomainContext>
                    <my:CatalogContext />
                </DataSource:DomainDataSource.DomainContext>
            </DataSource:DomainDataSource>
        </Grid.Resources>
            <Grid.RowDefinitions>
            <RowDefinition />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>
        <DataForm:DataForm
            x:Name="NewCategoryDataForm"
            Header="Category Information"  
            AutoGenerateFields="False" 
            AutoEdit="True" 
            AutoCommit="True"
            CommandButtonsVisibility="None"
            >
            <DataForm:DataForm.EditTemplate>
                <DataTemplate>
                    <StackPanel Orientation="Vertical">
                        <DataForm:DataField Label="Name">
                            <TextBox Text="{Binding Name, Mode=TwoWay}"/>
                        </DataForm:DataField>
                        <DataForm:DataField Label="Parent Category">
                            <ComboBox 
                                IsSynchronizedWithCurrentItem="False"
                                ItemsSource="{Binding Source={StaticResource LookupSource}, Path=Data}"
                                SelectedValue="{Binding ParentId, Mode=TwoWay}"
                                SelectedValuePath="Id"
                                DisplayMemberPath="Name"/>
                        </DataForm:DataField>
                        <DataForm:DataField Label="Short Description">
                            <TextBox Text="{Binding ShortDescription, Mode=TwoWay}"/>
                        </DataForm:DataField>
                        <DataForm:DataField Label="Long Description">
                            <TextBox Text="{Binding LongDescription, Mode=TwoWay}"/>
                        </DataForm:DataField>
                    </StackPanel>
                </DataTemplate>
            </DataForm:DataForm.EditTemplate>
        </DataForm:DataForm>

        <Button Content="Cancel" Click="CancelButtonClick" Width="75" Height="23" HorizontalAlignment="Right" Margin="0,12,0,0" Grid.Row="1" />
        <Button Content="OK" Click="OkButtonClick" Width="75" Height="23" HorizontalAlignment="Right" Margin="0,12,79,0" Grid.Row="1" />
    </Grid>
</controls:ChildWindow>